<?php
$lost='127.0.0.1';
$port='3306';
$username='root';
$pass='';
$link=@mysql_connect("$host:$port",$username,$pass) or die("失败");//1.链接认证
mysql_query("set names utf8");
mysql_select_db("fgd",$link);//2.选择 MySQL 数据库
$sql="show databases;";//显示所有数据库
//$sql="select count(*) from qq";//查询表
//$sql="create table gg (id int,name char(20),sex tinyint(1))engine=myisam charset=utf8;";//创表
//$sql="create table book (id int,name char(20))engine=myisam charset=utf8;";
//$sql="insert into gg (id,name,sex) values (1,'g',0)";//插入数据
//$sql="insert into book (id,name) VALUES (1,'10')";
//$sql="insert into gg (id,name,sex) values (1,'d',0)";//插入数据
//$sql="insert into book (id,name) VALUES (1,'20')";
//$sql="update gg set name='男' where id=1;";//修改数据
//$sql="update book set name='三国演义' where id=1;";
//$sql="update gg set id=2,sex=1,name='女' where name='d';";
//$sql="update book set name='水浒传',id=2 where name='20';";
$a=mysql_query($sql,$link);
var_dump($a);
//while($b=mysql_fetch_array($a)){
//    var_dump($b);
//}
//while($c=mysql_fetch_assoc($a)){
//    var_dump($c);
//}
while($d=mysql_fetch_row($a)){
    echo "<a style='padding:10px' href='mysql.php?database=$d[0]'>".$d[0]."</a>";
}
echo '<br/>';
if(!empty($_GET['database'])){
    $datab=$_GET['database'];
    mysql_select_db("$datab",$link);
    $sql1="show tables";
    $k=mysql_query($sql1,$link);
    while($b=mysql_fetch_array($k)){
        echo "<a style='padding:10px' href='mysql.php?database=$datab&table=$b[0]'>".$b[0]."</a>";
    }
}
if(!empty($_GET['table'])){
    $tab=$_GET['table'];
    $sql2="desc $tab;";
    $t=mysql_query($sql2,$link);
    while($c=mysql_fetch_row($t)){
        var_dump($c[0]);
    }
}
?>